home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
windows
/
alfacon1.zip
/
ALFACO.WAS
Wrap
Text File
|
1992-09-29
|
12KB
|
226 lines
;Alfacon.Was v1.00 Alphabetic number converter.
;****************************************************************************
;* *
;* ALFACON.WAS *
;* Copyright (C) 1992 Datastorm Technologies, Inc. *
;* All rights reserved *
;* *
;* Purpose: This is a script which will convert mixed alpha-numeric phone *
;* numbers into all numeric. *
;* *
;* This Windows ASPECT script allows the user to input a number, in any *
;* format, with spaces, parens, hyphens, or any allowable modem characters, *
;* and convert it into all numbers while leaving the spaces, parens, etc... *
;* *
;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming. *
;* DATASTORM makes no warranty of any kind, express or implied, including *
;* without limitation, any warranties of mechantability and/or fitness *
;* for a particular purpose. Use of this program is at your own risk. *
;* *
;* Author: Chris Brandow *
;* *
;****************************************************************************
;****************************************************************************
;* *
;* MAIN *
;* The procedure Main calls NumberInput which allows the user to input in *
;* the number for conversion. For example, 1 314 GIF DATA would be converted*
;* to 1 314 443 3282. *
;* *
;* Calls: NumberInput *
;* Modifies globals: none *
;* *
;****************************************************************************
proc Main
NumberInput()
endproc
;****************************************************************************
;* *
;* NUMBERINPUT *
;* *
;* The procedure NumberInput prompts the user for the number to convert. *
;* It helps if the number has alpha characters in it, otherwise it really *
;* doesn't need converting. *
;* The testing of the numbers is done in a function that is *
;* called from NumberInput. Since only numbers, alpha characters (ex- *
;* cluding Q and Z), the asterisk, and the comma are allowable characters, a*
;* test needs to be done on the string entered by the user. This test is *
;* done in the function legel_entry. It sets the flag in this procedure to *
;* tell us that an invalid character was entered into the phone number. *
;* *
;* Calls: LegalEntry *
;* Called by: Main *
;* Modifies globals: none *
;* *
;****************************************************************************
proc NumberInput
string InputNumber
integer flag
flag = 0 ; initializes the flag
while flag == 0
sdlginput "Converter" "Enter number:" InputNumber ; allow input
if success ; if successful
flag = LegalEntry(&InputNumber) ; test digits for alphas
if flag == 0 ; if an invalid character
ErrorEncountered() ; call the error procedure
endif
else ; if the cancel was hit
halt ; halt the program
endif
endwhile
usermsg "The number is %s" InputNumber ; output converted number
endproc
;****************************************************************************
;* *
;* LEGALENTRY(InputNumber) *
;* Returns: InputNumber = 0 showing that in invalid character was entered. *
;* The function LegalEntry is the function that tests the number that has *
;* been input by the user. A string of possible characters has been included*
;* as a local. This string is used so that if someone needs to add or take *
;* away characters, they may do so with ease and less confusion. *
;* The number that was entered by the user is pulled apart one character at *
;* a time and a strfind is done to test whether each character is a valid *
;* one. If it is not, an error will appear on the screen and the user will *
;* be allowed to either reenter the number or quit the program. If the *
;* number is in the list and is in position 16 or higher (meaning it was a *
;* letter), then control is passed to a conversion procedure which will do *
;* conversion and then pass the new character back to LegalEntry for a *
;* strpoke to be performed to include it into the final phone number. *
;* *
;* Calls: Convert2Number *
;* Called by: NumberInput *
;* Modifies globals: none *
;* *
;****************************************************************************
func LegalEntry:integer
strparm InputNumber
integer counter, NumberLength, EndValue, TempValue, StrPos
string TempString
string OKValues = "0123456789,*()- ABCDEFGHIJKLMNOPRSTUVWXY"
strupr InputNumber ; convert # to uppercase
strlen InputNumber NumberLength ; get length of #
EndValue = NumberLength - 1 ; set counter EndValue
; since positions start at 0
for counter = 0 upto EndValue
breakpoint
strpeek InputNumber counter TempValue ; get the ASCII value
strfmt TempString "%c" TempValue
if strfind OKValues TempString StrPos
if StrPos > 15
Convert2Number(&TempValue) ; call Convert2Number
strpoke InputNumber counter TempValue; insert character
endif
else
return(0)
endif
endfor
return(1) ; this return signals that
; the number was a numeral
endfunc
;****************************************************************************
;* *
;* CONVERT2NUMBER(TempValue) *
;* *
;* The procedure Convert2Number is what is activated if the user inputs *
;* an alpha character into the phone number. The program takes into con- *
;* sideration above in procedure LegalEntry if the character was a Q or a *
;* Z. Since these are not represented on the phone, they are not allowable *
;* entries. *
;* *
;* Calls: nothing *
;* Called by: LegalEntry *
;* Modifies globals: none *
;* *
;****************************************************************************
proc Convert2Number
intparm TempValue
if TempValue > 64 && TempValue < 68 ; test for A - C and turn
TempValue = 50 ; the strpoke value into 2
endif
if TempValue > 67 && TempValue < 71 ; test for D - F and turn
TempValue = 51 ; the strpoke value into 3
endif
if TempValue > 70 && TempValue < 74 ; test for G - I and turn
TempValue = 52 ; the strpoke value into 4
endif
if TempValue > 73 && TempValue < 77 ; test for J - L and turn
TempValue = 53 ; the strpoke value into 5
endif
if TempValue > 76 && TempValue < 80 ; test for M - O and turn
TempValue = 54 ; the strpoke value into 6
endif
if TempValue > 79 && TempValue < 84 ; test for P - S without Q,
TempValue = 55 ; as tested for above, and
endif ; set the strpoke value to 7
if TempValue > 83 && TempValue < 87 ; test for T - V and turn
TempValue = 56 ; the strpoke value into 8
endif
if TempValue > 86 && TempValue < 91 ; test for W - Y and turn
TempValue = 57 ; the strpoke value into 9
endif
endproc
;****************************************************************************
;* *
;* ERRORENCOUNTERED *
;* *
;* The procedure ErrorEncountered is called if the flag in the procedure *
;* NumberInput is set to a zero. This signals a zero and tells us that an *
;* invalid character was entered. It then asks if you wish to reenter the *
;* number or if you want to just forget about it. *
;* *
;* Calls: nothing *
;* Called by: NumberInput *
;* Modifies globals: none *
;* *
;****************************************************************************
proc ErrorEncountered
integer MsgValue
;****************************************************************************
;* MACRO DEFINITIONS *
;****************************************************************************
#define ERROR1MESSAGE "A character that could not be dialed was entered."
#define ERROR2MESSAGE "Would you like to try again?"
sdlgmsgbox "Error!" ERROR1MESSAGE EXCLAMATION OK MsgValue
sdlgmsgbox "Quit?" ERROR2MESSAGE QUESTION YESNO MsgValue
if MsgValue == 7 ; if the user says 'no' then
halt ; halt the program
endif
endproc